﻿using SQLDeployAnything.Data.Environment;
using System;
using System.Windows.Data;

namespace SQLDeploymentBuilder.UI.Converters
{
    public class StringToSSISStorage : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is string)
            {
                string sValue = (string)value;
                if (sValue.Equals(SSISConnection.SQLSERVER_STRING))
                    return SSISConnection.StorageLocation.SQLServer;
                else if (sValue.Equals(SSISConnection.FILESYSTEM_STRING))
                    return SSISConnection.StorageLocation.FileSystem;
            }
            return null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value is SSISConnection.StorageLocation)
            {
                SSISConnection.StorageLocation location = (SSISConnection.StorageLocation)value;
                switch (location)
                {
                    case SSISConnection.StorageLocation.FileSystem:
                        return SSISConnection.FILESYSTEM_STRING;
                    case SSISConnection.StorageLocation.SQLServer:
                        return SSISConnection.SQLSERVER_STRING;
                }
            }
            return null;
        }
    
    }
}
